<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/1 0001
 * Time: 下午 14:36
 */

namespace Home\Controller;

class SearchController extends DhtController
{
    public function cat_search(){
        $catId = I('get.cat_id');
//        echo $catId;
        $catModel = D('Admin/category');
        $searchFilter = $catModel->getSearchConditionByCatId($catId);
//        echo '<pre>';
//        var_dump($searchFilter);
//        exit;

        $goodsModel = D('Admin/Goods');
        $data = $goodsModel->cat_search($catId,2);
        $this->assign(array(
            'data'=>$data['data'],
            'page'=>$data['page'],
            'searchFilter'=>$searchFilter,
            'page_title'=>'京西商城',
            'cat1'=>'0',
            'page_keywords'=>'商城',
            'page_description'=>'商城',

        ));
        $this->display();
    }

    /***************************导航条 搜索框搜索************************/
    public function key_search(){
        $key = I('get.key');

//        echo '<pre>';
//        var_dump($key);
//        exit;
        $catModel = D('Admin/goods');
        $data = $catModel->key_search($key);

        // 根据上面搜索出来的商品计算筛选条件
        $catModel = D('Admin/Category');

        $searchFilter = $catModel->getSearchConditionByCatId($data['goods_id']);


        $this->assign(array(
            'data'=>$data['data'],
            'page'=>$data['page'],
            'searchFilter'=>$searchFilter,
            'page_title'=>'京西商城',
            'cat1'=>'0',
            'page_keywords'=>'商城',
            'page_description'=>'商城',

        ));
        $this->display();
    }
}